<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>账号</td>
                    <td>
                        <input type="text" v-model="date.name">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="date.pwd">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="登录" @click="login">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import axios from 'axios';
const routher = useRouter()
const login=()=>{
    axios.get("https://localhost:7258/api/User/Login",{params:date.value}).then(res=>{
        if(res.data.id==-1){
            alert("账号错误")
            return
        }
        if(res.data.id==-2){
            alert("密码错误")
            return
        }
        if(res.data.id>0){
            alert("登录成功")
            routher.push({path:"/ShowMember"})
        }
        else{
            alert("登录成功")
            routher.push({path:"/ShowMember"})
        }
    })
}
const date=ref({
    name:'',
    pwd:''
})
</script>

<style scoped>

</style>